/****
 * 登录
 ****/
;(function() {
	var module = {
		initInput: function () {
			var userName = localStorage.getItem("userName");
			if (userName) {
				$("input[name='userName']").val(userName);
			}
		},
		eventListner: function () {
			$("#login").click(function () {
				var userName = $("input[name='userName']").val().trim(),
					pwd = $("input[name='pwd']").val().trim();
				if (!userName) {
					alert("请输入用户名");
					return false;
				}
				if (!pwd) {
					alert("请输入密码");
					return false;
				}
				if ($("#chkRemember").attr("checked")) {
					localStorage.setItem("userName", userName);
				}
				$.ajax({
					url: "",
					type: "post",
					data: {
						userName: userName,
						pwd: pwd
					},
					dataType: "json",
					success: function (data) {
						location.href = "/Views/index.html";
					},
					error: function () {
						alert("帐号或密码输入错误");
					}
				})
			});
		},
		init: function () {
			module.initInput();
			module.eventListner();
		}
	};
	
	$(function () {
		module.init();
	});
}());